package com.db.entity;

import java.util.Date;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;
import org.springframework.stereotype.Repository;

@Repository
@Entity
@Table(name = "M_PROJECT")
public class Project {

    public String getTypeStr() {
        return typeStr;
    }

    public void setTypeStr(String typeStr) {
        this.typeStr = typeStr;
    }

    public static enum EnumProjectType {
		NULL, TECH_PROJECT, PROVINCE_LEVEL, CITY_LELVEL, COUNTY_LELVEL, TOTAL
	}

	public static enum EnumProjectStatus {
		NULL,UNSTARTED, STARTED, CHECKIN, FINISHED, MAINTENANCE,TOTAL
	}
	
	public static String mapEnumProjectStatus(EnumProjectStatus status) {
		switch (status) {
		case UNSTARTED: { return "未开始";}
		case STARTED: { return "已开始";}	

		default:
			break;
		}
		return "未知";
	}

    public static String getProjectType(EnumProjectType type) {
        switch (type)
        {
            case TECH_PROJECT: return "科技项目";
            case PROVINCE_LEVEL: return "省调项目";
            case CITY_LELVEL: return "地调项目";
            case COUNTY_LELVEL: return "县调项目";
            default: return new String();
        }
    }

    public static EnumProjectType getProjectType(String str) {
        if(str.trim().equals("科技项目")) {
            return EnumProjectType.TECH_PROJECT;
        } else if(str.trim().equals( "省调项目" )) {
            return EnumProjectType.PROVINCE_LEVEL;
        } else if(str.trim().equals("地调项目")) {
            return EnumProjectType.CITY_LELVEL;
        } else if(str.trim().equals("县调项目")) {
            return EnumProjectType.COUNTY_LELVEL;
        }

        return EnumProjectType.NULL;
    }


	@Id
	@Column(name = "PROJECT_UUID",length=32)
	@GenericGenerator(name="systemUUID",strategy="uuid")
	@GeneratedValue(generator="systemUUID")
	private String uuid;
	@Column(name = "PROJECT_ID", length=8)
	private int projectId;
	@Column(name = "PROJECT_NAME", length=64)
	private String projectName;
	@Enumerated
	private EnumProjectType type;
	@Enumerated
	private EnumProjectStatus status;
	private int startYear;
	private Date startDate;
	private Date endDate;

    @Transient
    private String typeStr;

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public int getProjectId() {
		return projectId;
	}

	public void setProjectId(int projectId) {
		this.projectId = projectId;
	}

	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	public EnumProjectType getType() {
		return type;
	}

	public void setType(EnumProjectType type) {
		this.type = type;
	}

	public EnumProjectStatus getStatus() {
		return status;
	}

	public void setStatus(EnumProjectStatus status) {
		this.status = status;
	}

	public int getStartYear() {
		return startYear;
	}

	public void setStartYear(int startYear) {
		this.startYear = startYear;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

}
